<template>
    <el-card>
        <h2>{{ teacher.name }}</h2>
      <el-form :model="teacher" ref="formRef">
            <el-form-item label="教学科目">
                <el-select v-model="form.subjects" multiple placeholder="请选择教学科目">
                    <el-option label="网站开发" value=" 网站前端开发"></el-option>
                    <el-option label="专业英语" value=" 专业英语"></el-option>
                    <el-option label="Python 程序设计" value=" Python 程序设计"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">保存</el-button>
            </el-form-item>
      </el-form>
    </el-card>
</template>

<script setup>
import { ref } from 'vue'

const formRef = ref(null)
const props = defineProps({
    teacher: {
        type: Object,
        required: true
    }
})

const emit = defineEmits(['submit'])


const onSubmit = () => {
    formRef.value.validate((valid) => {
        if(valid) {
            emit('submit');
        }
    });
};

</script>